#!/usr/bin/env bash

# 使用说明　注意提前修改修改ＩＰ地址　和　hostname，手动增加hosts
# 可以使用命令 hostnamectl set-hostname XXXX
# 手动修改ip  ls /etc/sysconfig/network-scripts/下面的 ifcfg-XXXX
# 手动增加hosts解析　/etc/hosts

#MASTERHOSTNAME="full-master-node"
#MASTERIP="192.168.9.190"

# 关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service

# 关闭swap
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
setenforce 0

# 启用ip4转发和ip6的桥接功能 ipv4这个点在很多网络的文章中是漏掉的，会导致kube-proxy不能正常工作
cat <<EOF > /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

# 关闭 selinu
sed -i 's/SELINUX=permissive/SELINUX=disabled/' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux

# 生效配置
sysctl --system

# 安装docker (cenos7 以上会安装docker 1.13.1)
yum install -y docker
systemctl enable docker
systemctl start docker

#　bash命令辅助工具
yum install bash-completion -y
echo "source <(kubectl completion bash)" >> ~/.bashrc


################以上无论是node还是master都需要准备的########################